package com.example.hello.hello.api.remote;

import com.example.hello.hello.api.ApiHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class OSAppApi {

    /**
     * 登陆
     * 
     * @param userphone  s手机号
     * @param password  md5加密后的
     * @param handler
     */
    public static void login(String userphone, String password,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mobile", userphone);
        params.put("password", password);
        String loginurl = "app_login.jspx";
        ApiHttpClient.post(loginurl,params,handler);
    }
//    xiug修改密码
//var url = main_url + '/app_passwordsave.jspx?mobile='+mobile+'&password='+repass;
    public static void EditPassword(String mobile,String new_password,AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mobile", mobile);
        params.put("password", new_password);
        String loginurl = "app_passwordsave.jspx";
        ApiHttpClient.get(loginurl,params,handler);
    }
//    var url = main_url + '/app_SenSms.jspx?mobile='+mobile+'&site='+_site_id+'&APPID='+dxSMSiP+'&SMSModel='+dxSMSmodel+'&repassword='+repass;
    public static void SenSms(String mobile,String site_id,String APPID,String SMSModel,String repassword, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mobile", mobile);
        params.put("site", site_id);

        params.put("APPID", APPID);
        params.put("SMSModel", SMSModel);
        params.put("repassword", repassword);

        String loginurl = "app_SenSms.jspx";
        ApiHttpClient.get(loginurl,params,handler);
    }
//    var url = main_url + '/app_get_top_list.jspx?parentId=' + parentId;
    public static void getTopbyCheanlId(String parentId, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("parentId", parentId);
        String loginurl = "app_get_top_list.jspx";
        ApiHttpClient.get(loginurl,params,handler);
    }
//    var url = main_url + '/app_get_channelm_mng.jspx?parentId=' + parentId;
    public static void getCheanlId(String parentId, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("parentId", parentId);
        String loginurl = "app_get_channelm_mng.jspx";
        ApiHttpClient.get(loginurl,params,handler)    ;
    }
//    var url = main_url + '/app_get_content_list.jspx?channelId='+channelId+'&pageNo='+pageNo;
//    if(count != undefined){
//        url += '&count='+count;
//    }
    public static void getContentList(String channelId,String pageNo,String count, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("channelId", channelId);
        params.put("pageNo", pageNo);
        params.put("count", count);
        String loginurl = "app_get_content_list.jspx.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }

//    var url = main_url + '/app_reg.jspx';
//    var data={siteid:_site_id,username:username,mobile:telephone,password:password};
//    return getPostResult(url,data);
    public static void getCheanlId(String siteid,String username,String mobile,String password, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("siteid", siteid);
        params.put("username",username);
        params.put("mobile",mobile);
        params.put("password",password);
        String loginurl = "app_reg.jspx";
        ApiHttpClient.post(loginurl,params,handler);
    }


//        var	url = main_url + '/app_enroll_count.jspx?type='+type+'&isNo='+isNo+'&applay='+applay+'&contentId='+contentId+'&userId='+userid+'&siteId='+_site_id+'&pageNo='+pageNo+'&count='+count+'&channelId='+channelId;
    public static void app_enroll_count(String type,String isNo,String applay,String contentId,String userId,String siteId,String pageNo,String count,String channelId, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();

        params.put("type", type);
        params.put("isNo", isNo);
        params.put("applay", applay);
        params.put("contentId", contentId);
        params.put("userId", userId);
        params.put("siteId", siteId);
        params.put("pageNo", pageNo);
        params.put("count", count);
        params.put("channelId", channelId);
        String loginurl = "app_enroll_count.jspx";
        ApiHttpClient.get(loginurl,params,handler)   ;
    }

//        var url =  main_url + '/app_collect.jspx?';
//        if(contentId != null || contentId != undefined){
//        url = url + 'contentId=' + contentId ;
//        }
//        if(userId != null || userId != undefined){
//        url = url + '&userId=' + userId ;
//        }
//        if(operate != null || operate != undefined){
//        url = url + '&operate='+operate;
//        }


    public static void app_collect(String contentId,String userId,String operate, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("contentId", contentId);
        params.put("userId", userId);
        params.put("operate", operate);
        String loginurl = "app_collect.jspx";
        ApiHttpClient.get(loginurl,params,handler)  ;
    }


//        var url = main_url + '/app_collection_list.jspx?channelId='+channelId+'&userId='+userId+'&siteId='+_site_id+'&pageNo='+pageNo+'&count='+count;

    public static void app_collection_list(String channelId,String userId,String pageNo,String count, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("channelId", channelId);
        params.put("userId", userId);
        params.put("pageNo", pageNo);
        params.put("count", count);
        String loginurl = "app_collection_list.jspx";
        ApiHttpClient.get(loginurl,params,handler);
    }
//        var url = main_url + '/content_up.jspx?contentId=' + contentId;
    public static void content_up( String contentId, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("contentId", contentId);
        String loginurl = "content_up.jspx.jspx";
        ApiHttpClient.get(loginurl,params,handler);
    }
//        var url = main_url + '/content_down.jspx?contentId=' + contentId;
    public static void content_down(String contentId, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("contentId", contentId);
        String loginurl = "content_down.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }
//        var url= main_url + '/app_comment.jspx';
//        var data={contentId:contentId,score:1,text:content,siteId:_site_id,userId:userid};
    public static void app_comment(String contentId,String score,String text,String siteId,String userId, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("contentId", contentId);
        params.put("score", score);
        params.put("text", text);
        params.put("siteId", siteId);
        params.put("userId", userId);
        String loginurl = "app_comment.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }
//        var url = main_url + '/app_get_content_list_by_comment.jspx?channelId='+channelId+'&userId='+userid+'&siteId=' + _site_id + '&pageNo=' + pageNo + '&count='+count;

    public static void app_get_content_list_by_comment(String channelId,String siteId,String userId,String pageNo,String count, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("channelId", channelId);
        params.put("siteId", siteId);
        params.put("userId", userId);
        params.put("pageNo", pageNo);
        params.put("count", count);
        String loginurl = "app_get_content_list_by_comment.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }

//        var url =  main_url + '/app_comment_list.jspx?contentId=' + contentId + '&siteId=' + _site_id + '&pageNo=' + pageNo + '&recommend=0&checked=1';

    public static void app_comment_list(String contentId,String siteId,String pageNo,String recommend,String checked,AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("contentId", contentId);
        params.put("siteId", siteId);
        params.put("pageNo", pageNo);
        params.put("recommend", recommend);
        params.put("checked", checked);
        String loginurl = "app_comment_list.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }

//        url = main_url + '/app_get_content_list.jspx?channelId=' + channelId;
//        if(page != null || page != undefined){
//        url = url + '&pageNo=' + page;
//        }
//        if(inputUserId != null || inputUserId != undefined){
//        url = url + '&inputUserId=' + inputUserId;
//        }
//        if(title != null || title != undefined){
//        url = url + '&queryTitle=' + title;
//        }
//        if(userId != null || userId != undefined){
//        url = url + '&userId=' + userId + '&siteId=' + _site_id;
//        }
//        if(count != undefined){
//        url += '&count='+count;
//        }
//        //进行中文编码
//        url = encodeURI(url);
//        url = encodeURI(url);
//        console.log(url);
    public static void app_get_content_list(String channelId,String pageNo,String inputUserId,String title,String userId,String count, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("channelId", channelId);
        params.put("page", pageNo);
        params.put("inputUserId", inputUserId);
        params.put("title", title);
        params.put("userId", userId);
        params.put("count", count);
        String loginurl = "app_get_content_list.jspx";
        ApiHttpClient.post(loginurl,params,handler); ;
    }
//        var url = main_url + '/app_save.jspx';
//
//        var data={id:id,password:password,userimg:userimg,gender:gender,realname:realname};
//        console.log(JSON.stringify(data));
//        return getPostResult(url,data);
    public static void app_save(String id,String password,String userimg,String gender,String realname,AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("id", id);
        params.put("password", password);
        params.put("userimg", userimg);
        params.put("gender", gender);
        params.put("realname", realname);
        String loginurl = "app_save.jspx";
        ApiHttpClient.post(loginurl,params,handler); ;
    }
//        var url = main_url + '/app_getmap_list.jspx?type='+type+'&userId'+userId+'&contentId'+contentId+'&pageNo'+pageNo;
    public static void app_getmap_list(String type,String userId,String contentId,String pageNo,AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("type", type);
        params.put("userId", userId);
        params.put("pageNo", pageNo);
        params.put("contentId", contentId);
        String loginurl = "app_getmap_list.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }
//        var url = main_url + '/app_user_enroll.jspx?userId='+userid+'&contentId='+contentid+'&siteId='+_site_id+'&channel='+channel;
    public static void app_user_enroll(String userId,String contentId,String siteId,String channel,AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("userId", userId);
        params.put("contentId", contentId);
        params.put("siteId", siteId);
        params.put("channel", channel);
        String loginurl = "app_user_enroll.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }

//        var url= main_url + '/app_add_content.jspx';
//        var data={hbegin:hbegin,hend:hend,hsxrs:hsxrs,origin:origin,gpic:gpic,title:title,text:text,userId:userId,channelId:channelId,siteId:_site_id,modelId:modelId,description:description,imgpaths:imgpaths};
//        console.log(JSON.stringify(data));
    public static void app_add_content(String hbegin,String hend,String hsxrs,String origin,String gpic,String title,String text,String userId,String channelId,String siteId,String modelId,String description,String imgpaths, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("hbegin", hbegin);
        params.put("hend", hend);
        params.put("hsxrs", hsxrs);
        params.put("origin", origin);
        params.put("gpic", gpic);
        params.put("title", title);
        params.put("text", text);
        params.put("userId", userId);
        params.put("channelId", channelId);
        params.put("siteId", siteId);
        params.put("modelId", modelId);
        params.put("description", description);
        params.put("imgpaths", imgpaths);
        String loginurl = "app_add_content.jspx";
        ApiHttpClient.post(loginurl,params,handler); ;
    }

//        var url = main_url + '/content_view.jspx?contentId='+contentId;
    public static void content_view(String contentId,AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("contentId", contentId);
        String loginurl = "content_view.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }
//        var url = main_url + '/app_get_wy_ly_by.jspx?siteId='+_site_id +'&contentId='+contentId+'&type='+type+'&pageNo='+pageNo+'&count='+count+'&isContent='+isContent+'&id='+id;
    public static void app_get_wy_ly_by(String siteId,String contentId,String type,String pageNo, String count,String isContent,String id, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("siteId", siteId);
        params.put("contentId", contentId);
        params.put("type", type);
        params.put("pageNo", pageNo);
        params.put("count", count);
        params.put("isContent", isContent);
        params.put("id", id);
        String loginurl = "app_get_wy_ly_by.jspx";
        ApiHttpClient.get(loginurl,params,handler) ;
    }
}
